package jsonthread_14_7_2013;


import java.util.ArrayList;
import java.util.List;

import org.apache.http.NameValuePair;
import org.apache.http.message.BasicNameValuePair;

import android.os.Handler;


public class ServiceDelegate {
	private static final String PARAM_ORIGIN = "origin";
	private static final String PARAM_DESTINATION = "destination";
	private static final String PARAM_SENSOR = "sensor";
	public static final String BASE_URL = "http://maps.googleapis.com/maps/api/directions/json";

	// origin=tran_duy_hung_ha_noi&destination=tran_dai_nghia_ha_noi&sensor=false

	public static Thread getJsonMap(final String origin, final String destination,
			final String sensor, final Handler handler) {

		final List<NameValuePair> params = new ArrayList<NameValuePair>();
		params.add(new BasicNameValuePair(PARAM_ORIGIN, origin));
		params.add(new BasicNameValuePair(PARAM_DESTINATION, destination));
		params.add(new BasicNameValuePair(PARAM_SENSOR, sensor));
		final Runnable runnable = new Runnable() {
			public void run() {
				String s = HttpConnectionUtils.getFromURL(BASE_URL, params, handler, null).toString();
			}
		};
		return HttpConnectionUtils.performOnBackgroundThread(runnable);
	}

}
